package com.wuwei.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.wuwei.service.PaymentHystrixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: OrderHystrixController <br>
 * @date: 2021/2/9 15:50 <br>
 * @author: wuwei666 <br>
 * @version: 1.0 <br>
 */
@RestController
@Slf4j
public class OrderHystrixController {
    @Autowired
    private PaymentHystrixService paymentHystrixService;

    @GetMapping("comsumer/ok/{id}")
    public String hy_ok(@PathVariable("id") Integer id){
        return paymentHystrixService.payment_ok(id);
    }


    /*@HystrixCommand(fallbackMethod = "fallback_Method",commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "1000")
    })*/
    @GetMapping("comsumer/timeout/{id}")
    @HystrixCommand
    public String timeout_hy(@PathVariable("id") Integer id){
        return paymentHystrixService.payment_timeout(id);
    }

    /*public String fallback_Method(@PathVariable("id") Integer id){
        return "消费者80,一秒时间到" + id;
    }*/
}
